﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using ModuleDALCore;

namespace DAL
{
    public class LOAITHEDAO:DALBase
    {
        public LOAITHEDAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPLOAITHE"; }
            set { _SpName = value; }
        }
        public DataTable GetListLOAITHE()
        {
            dt = new DataTable();
           
            try
            {
                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LOAITHE(), null), ConvertClassToArray.GetValues(new LOAITHE(), 0));
                
            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LOAITHE"); }
            return dt;
        }
		public List<LOAITHE> GetListLOAITHEs()
		{
			dt = new DataTable();
			List<LOAITHE> ds = new List<LOAITHE>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LOAITHE(), null), ConvertClassToArray.GetValues(new LOAITHE(), 0));
				ds = (List<LOAITHE>)ConvertDatatableToList.ConvertTo<LOAITHE>(dt);
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LOAITHE"); }
			return ds;
		}
        public String CreatenewId()
        {
            try
            {
                return "LT" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new LOAITHE(), null), ConvertClassToArray.GetValues(new LOAITHE(), 1));

            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't Create new LOAI THE"); }
        }
        public bool INSERT(LOAITHE cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Insert new LOAI THE"); }
        }
        public bool UPDATE(LOAITHE cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Update  LOAI THE"); }
        }
        public bool DELETE(LOAITHE cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Delete  LOAI THE"); }
        }
    }
}
